#include <iostream>
#include <string>
//
// Created by Asus on 2025/6/1.
//
using namespace std;

class Building {
    //告诉编译器 goodGay全局函数 是 Building类的好朋友，可以访问类中的私有内容
    friend void goodGay(Building *building);
public:
    Building() {
        this->m_SittingRoom = "客厅";
        this->m_BedRoom = "卧室";
    }

string m_SittingRoom; //客厅

private:
    string m_BedRoom; //卧室
};

void goodGay(Building * building)
{
    cout << "好基友正在访问： " << building->m_SittingRoom << endl;
    cout << "好基友正在访问： " << building->m_BedRoom << endl;
}

void demo01() {
    Building b;
    goodGay(&b);
}

class Building2;
class GoodGay {
    public:
    GoodGay();
    void visit();
    private:
    Building2 *m_Building;
};
class Building2 {
    friend class GoodGay;
    public:
    Building2();
    string m_SittingRoom;
private:
    string m_BedRoom;
};

Building2::Building2() {
    this->m_SittingRoom = "客厅";
    this->m_BedRoom = "卧室";
}

GoodGay::GoodGay() {
    m_Building = new Building2;
}

void GoodGay::visit()
{
    cout << "好基友正在访问" << m_Building->m_SittingRoom << endl;
    cout << "好基友正在访问" << m_Building->m_BedRoom << endl;
}

void demo02() {
    GoodGay gg;
    gg.visit();
}

int main() {
    // demo01();
    demo02();
    return 0;
}
